Photograph processing method and system

ABSTRACT

Embodiments of the present invention provide a photograph processing method and system. The method includes: performing face detection on a photograph to obtain a detected human face; performing alignment on the detected human face, so as to obtain contour points of a left eye and a right eye of the detected human face; separately calculating a left eye area, being an area of the left eye, and a right eye area, being an area of the right eye, according to the contour points of the left eye and the right eye; performing stretching transformation on each pixel in the left eye area and the right eye area to generate a stretched left eye area and a stretched right eye area; and performing histogram equalization processing on the stretched left eye area and the stretched right eye area, so as to generate a processed photograph.

RELATED APPLICATION

This application is a continuation application of PCT Patent ApplicationNo. PCT/CN2016/101588, filed on Oct. 9, 2016, which claims priority toChinese Patent Application No. 201510943006.7, filed with the ChinesePatent Office on Dec. 16, 2015, entitled “PHOTOGRAPH PROCESSING METHODAND SYSTEM”, the entire content of both of which is incorporated hereinby reference.

FIELD OF THE TECHNOLOGY

The present disclosure relates to the field of image processing and, inparticular, to a photograph processing method and system.

BACKGROUND OF THE DISCLOSURE

Along with the popularity of digital cameras and smartphones, more andmore pictures are taken by such devices. However, the effect ofphotographs taken may be affected by various factors, such as light,photography instrument, personal appearance, shooting angle, shootingposture, and lens distortion. Eyes are always regarded as windows to thesoul, and are one of the most important parts of portrait photography.Therefore, adjustment is often made on eyes during post-processing of aphotograph.

Currently, common processing methods are as follows:

1. Using professional software such as Photoshop to do the processing.However, such a method requires an operator to have high professionalexpertise and involves complex operations, and is particularlytime-and-labor-consuming when there are a large quantity of photographsto be processed.

2. Using smart software applications such as Meitu to do the processing.Although such a method is easy to operate, the effect of processing oneyes usually causes distortion. In addition, such a method is also notsuitable for processing of a large quantity of photographs.

SUMMARY

In view of the above technical problems, an objective of the presentdisclosure is to provide a photograph processing method and system, soas to resolve technical problems of high professional expertise, complexoperations, distortion of processing effect, and beingtime-and-labor-consuming when processing a large quantity of photographsin the existing technology.

To resolve the foregoing technical problems, embodiments of the presentinvention provide a photograph processing method, including: performingface detection on a photograph to obtain a detected human face;performing alignment on the detected human face, so as to obtain contourpoints of a left eye and a right eye of the detected human face;separately calculating a left eye area, being an area of the left eye,and a right eye area, being an area of the right eye, according to thecontour points of the left eye and the right eye; performing stretchingtransformation on each pixel in the left eye area and the right eye areato generate a stretched left eye area and a stretched right eye area;and performing histogram equalization processing on the stretched lefteye area and the stretched right eye area, so as to generate a processedphotograph.

To resolve the foregoing technical problems, the embodiments of thepresent invention further provide a photograph processing system. Thephotograph processing system includes a memory storing instructions; anda processor coupled to the memory. When executing the instructions, theprocessor is configured for: performing face detection on a photographto obtain a detected human face; performing alignment on the detectedhuman face, so as to obtain contour points of a left eye and a right eyeof the detected human face; separately calculating a left eye area,being an area of the left eye, and a right eye area, being an area ofthe right eye, according to the contour points of the left eye and theright eye; performing stretching transformation on each pixel in theleft eye area and the right eye area to generate a stretched left eyearea and a stretched right eye area; and performing histogramequalization processing on the stretched left eye area and the stretchedright eye area, so as to generate a processed photograph.

To resolve the foregoing technical problems, the embodiments of thepresent invention further provide a non-transitory computer-readablestorage medium, which contains computer-executable instructions for,when executed by a processor, performing a photograph processing method.The method includes: performing face detection on a photograph to obtaina detected human face; performing alignment on the detected human face,so as to obtain contour points of a left eye and a right eye of thedetected human face; separately calculating a left eye area, being anarea of the left eye, and a right eye area, being an area of the righteye, according to the contour points of the left eye and the right eye;performing stretching transformation on each pixel in the left eye areaand the right eye area to generate a stretched left eye area and astretched right eye area; and performing histogram equalizationprocessing on the stretched left eye area and the stretched right eyearea, so as to generate a processed photograph.

Other aspects of the present disclosure can be understood by thoseskilled in the art in light of the description, the claims, and thedrawings of the present disclosure.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic diagram of an application environment of aphotograph processing method and system according to embodiments of thepresent invention.

FIG. 2 is a schematic flowchart of a photograph processing methodaccording to an embodiment of the present invention;

FIG. 3 is a schematic flowchart of a photograph processing methodaccording to another embodiment of the present invention;

FIG. 4 is a schematic diagram of modules of a photograph processingsystem according to another embodiment of the present invention;

FIG. 5 is a schematic diagram of modules of a photograph processingsystem according to another embodiment of the present invention;

FIG. 6 is a schematic diagram of an interface of a photograph processingmethod and system according to another embodiment of the presentinvention;

FIG. 7 is a schematic diagram of contour points of a photographprocessing method and system according to another embodiment of thepresent invention; and

FIG. 8 is a schematic diagram of a terminal according to an embodimentof the present invention.

DESCRIPTION OF EMBODIMENTS

Referring to the drawings in the accompanying drawings, same componentsymbols represent same components. The principle of the presentdisclosure is described by way of example in a proper computingenvironment. The following descriptions are specific embodiments of thepresent invention based on the examples, and should not be construed asa limitation to other embodiments of the present invention that are notdescribed herein in detail.

That is, the principle of the present disclosure does not represent as alimitation, and a person skilled in the art may be able to learn thatmultiple following steps and operations may also be implemented inhardware. The principle of the present disclosure is performed by usingmany other general-purpose or specific-purpose operations,communications environment, or configurations.

FIG. 1 is a schematic diagram of an application environment of aphotograph processing method and system according to embodiments of thepresent invention. Referring to FIG. 1, the application environmentincludes a terminal device 10, a cloud service platform 20, and acommunications network 30.

It can be understood that the terminal device 10, such as a mobile phone11, a computer 12, or a camera 13, and other terminal devices with aphotograph storage function, may be installed with or linked, by using aweb page, to the processing method or processing system provided in thepresent disclosure, so as to beautify photographs.

The cloud service platform 20 is configured to provide the photographprocessing method and system according to the embodiments of the presentinvention by providing an application package or by means of a web pagelink.

That is, a processing process of the embodiments of the presentinvention may be implemented in the terminal device 10 by downloading anapplication package, or may be implemented on the cloud service platform20 by means of a web page link.

The processing process is briefly described as follows: performing facedetection on a photograph; performing alignment on a detected humanface, so as to obtain contour points of two eyes; separately calculatinga left eye area and a right eye area according to the contour points ofthe two eyes; performing stretching transformation on each pixel in theleft eye area and the right eye area; and performing histogramequalization processing on the stretched left eye area and the stretchedright eye area, so as to generate a processed photograph.

The communications network 30 is configured to provide a datatransmission channel between the terminal device 10 and the cloudservice platform 20, and includes a wireless network and a wirednetwork. The wireless network includes one or a combination of more thanone of a wireless wide area network, a wireless local area network, awireless metropolitan area network, or a wireless personal area network.

The solution may be applied to an open platform of Tencent YouTu toprocess a photograph, so as to form an effect of improved eyeappearance. Referring to the following embodiments, a photographprocessing method, a photograph processing system, and an effect of aphotograph processing method and system are illustrated. It can beunderstood that the various embodiments all have consistent designideas. Furthermore, for a part that is not described in detail in anembodiment, such detailed description may be obtained from the entirespecification, and features in the various embodiments may be combinedor replaced.

FIG. 2 is a basic schematic flowchart of a photograph processing method.The photograph processing method is usually executed in a terminaldevice. Referring to FIG. 2, the photograph processing method includesthe followings.

S201, performing face detection on a photograph or image.

Performing detection on a human face is to detect positions of all humanfaces and corresponding face attributes in a specified image. Thespecified image may be a local image or a network connection address,and the processing may be on a single image, or batch processing.

Specifically, the face detection may include the followings.

1. performing detection on the image to determine the position of thehuman face (x, y, w, h), so as to describe the position, the width, andthe height of a human face frame, such as an upper left cornerhorizontal coordinate x of the human face frame, an upper left cornervertical coordinate y of the human face frame, the width of the humanface frame, and the height of the human face frame.

2. detecting the face attributes according to the position of the humanface, the face attributes including but not limited to one of gender,age, expression, posture (pitch, roll, and yaw), or glasses.

In addition, the face detection may further include the followings.

3. detecting whether a mode of the photograph is a normal mode, where anabnormal mode is usually a big face mode, and, for example, a common bigface mode is an ID photograph or a selfie.

4. detecting the number of the human faces in the photograph todetermine whether to process all the human faces in the photograph.

S202, performing alignment on the detected human face, so as to obtaincontour points of two eyes of the human face.

Specifically, the step of alignment includes:

1. locating facial features of the human face and calculating contourpoints constituting the human face. For example, 88 contour points areused, including eyebrows (8 points at both left and right), eyes (8points at both left and right), a nose (13 points), a mouth (22 points),and a face profile (21 points). It can be understood that, the contourpoints used as an example herein should not be regarded as a limitationto the present disclosure; the number of the contour points may beincreased or reduced and positions of the contour points may bere-planned as required.

2. extracting contour points of a left eye and contour points of a righteye from the contour points.

In the above example, eight contour points at both the left and theright are used, and an x value (x-axis coordinate) and a y value (y-axiscoordinate) of each of the eight contour points of the left eye and an xvalue and a y value of each of the eight contour points of the right eyeare obtained.

S203, separately calculating a left eye area and a right eye areaaccording to the contour points of the two eyes.

S204, performing stretching transformation on each pixel in the left eyearea and the right eye area.

Specifically, the following steps are included:

1. decomposing each pixel in the left eye area and the right eye areainto a red attribute value, a green attribute value, and a blueattribute value; and

2. performing stretching transformation on the red attribute value, thegreen attribute value, and the blue attribute value to generate astretched left eye area and a stretched right eye area.

The step of stretching transformation specifically includes:

2.1. obtaining original color attribute values. For example, the colorattribute values may include red, green, or blue. In one embodiment, thedecomposed red attribute value, green attribute value, and blueattribute value may be used as the original color attribute values.

2.2. separately inserting the original color attribute values into asine function to perform stretching, so as to generate stretched colorattribute values. A transformation function formed by the sine functionis:

F(c)=(sin((c+1.57)*3)+1)/2 0=<c=<1;

where F(c), being a transformation function, can perform stretchingtransformation on a smaller value or a larger value to scale up orenlarge the center area of the eye (e.g., the pupil of the eye) andscale down or reduce the edge area of the eye (e.g., the white area ofthe eye), so that the eyes are rounder and brighter. In addition, thetransformation range is controllable, and the eyes will not be too largeto cause distortion; and

the stretched or transformed attribute value is:

C=255*F(c/255.0), where c is the red attribute value, the greenattribute value, or the blue attribute value. Taking pixels in the lefteye area as an example, original RGB channel values of a pixel are rgb,so that the transformed RGB values are:

R=255*F(r/255.0)

G=255*F(g/255.0)

B=255*F(b/255.0)

2.3. separately forming the stretched left eye area and the stretchedright eye area according to the stretched color attribute values.

S205, performing histogram equalization processing on the stretched lefteye area and the stretched right eye area, so as to generate a processedphotograph.

By means of the histogram equalization processing, gray scales with alarger number of pixels in the left eye area and the right eye area arebroadened, and gray scales with a smaller number of pixels arecompressed, thereby expanding the dynamic range of the original pixels,and improving contrast and variation of gray scale tone, so that thestretched photograph is clearer.

In the photograph processing method provided in this embodiment of thepresent invention, a left eye area and a right eye area are calculatedfrom a detected human face, and then stretching transformation isperformed on each pixel in the eye areas, so as to generate a processedphotograph, having an effect of automatically beautifying the eyeswithout the need for manual operation. In addition, the processingeffect is within a controllable range and distortion is not easy tooccur.

In another embodiment of the present disclosure, a photograph processingmethod is provided. FIG. 3 is a detailed schematic flowchart of aphotograph processing method. The photograph processing method may beexecuted in a terminal device or a cloud service platform. Referring toFIG. 3, including the steps shown in FIG. 2, the photograph processingmethod includes the followings.

S301, displaying an operation interface of the processing method, theoperation interface including at least a select option, a beautifyoption, and a save option.

It can be understood that this is supplemental to the automaticbeautification provided in the above embodiments. That is, selecting ato-be-processed photograph is performed by a user manually, so that awaste of processing resources caused by processing excessive photographsby a terminal device can be effectively reduced.

S302, selecting the to-be-processed photograph using the select option.

It can be understood that the to-be-processed photograph may be selectedby selecting a single photograph, a batch of photographs, a localphotograph, or a network photograph, etc.

S303, decoding the selected photograph to generate an RGB-formatphotograph.

The RGB format, also referred to as a color mode, obtains various colorsby changing three color channels of red (R), green (G), and blue (B),and overlay among them. RGB represents colors of the three channels ofred, green, and blue. Such a standard almost includes all colors thatcan be perceived by human eyes, and is one of the current most widelyused color systems.

S304, starting face detection on the selected photograph by selectingthe beautify option from the operation interface.

In this step, the beautify option is mainly to beautify the eyes, andmay also include other beautifying steps, such as beautifying skin orremoving moles. Details are not further described herein.

S201, performing the face detection on the photograph.

Performing detection on a human face is to detect a position of thehuman face in photograph, corresponding face attributes, the mode of thephotograph, the number of the human faces, and so on.

S202, performing alignment on the detected human face, so as to obtaincontour points of two eyes of the human face.

Specifically, the step of alignment includes:

1. locating facial features of the human face and calculating contourpoints constituting the human face.

2. extracting contour points of a left eye and contour points of a righteye from the contour points.

S203, separately calculating a left eye area and a right eye areaaccording to the contour points of the two eyes.

S204, performing stretching transformation on each pixel in the left eyearea and the right eye area.

Specifically, the following steps are included:

1. decomposing each pixel in the left eye area and the right eye areainto a red attribute value, a green attribute value, and a blueattribute value.

2. performing stretching transformation on the red attribute value, thegreen attribute value, and the blue attribute value to generate astretched left eye area and a stretched right eye area.

The step of stretching transformation specifically includes:

2.1. obtaining original color attribute values. For example, the colorattribute values may include red, green, or blue;

2.2. separately inserting the original color attribute values into asine function to perform stretching, so as to generate stretched colorattribute values. A transformation function formed by the sine functionis:

F(c)=(sin((c+1.57)*3)+1)/2 0=<c=<1;

where F(c), being a transformation function, can perform stretchingtransformation on a smaller value or a larger value to scale up orenlarge the center area of the eye and scale down or reduce the edgearea of the eye, so that the eyes are rounder and brighter. In addition,the transformation range is controllable, and the eyes will not be toolarge to cause distortion; and

the stretched or transformed attribute value is:

C=255*F(c/255.0), where c is the red attribute value, the greenattribute value, or the blue attribute value. Taking pixels in the lefteye area as an example, original RGB channel values of a pixel are rgb,so that the transformed RGB values are:

R=255*F(r/255.0)

G=255*F(g/255.0)

B=255*F(b/255.0)

2.3. separately forming the stretched left eye area and the stretchedright eye area according to the stretched color attribute values.

S205, performing histogram equalization processing on the stretched lefteye area and the stretched right eye area, so as to generate a processedphotograph.

By means of the histogram equalization processing, gray scales with alarger number of pixels in the left eye area and the right eye area arebroadened, and gray scales with a smaller number of pixels arecompressed, thereby expanding the dynamic range of the original pixels,and improving contrast and variation of gray scale tone, so that thestretched photograph is clearer.

S305, by using the save option from the operation interface, encodingthe photograph after the equalization processing to generate a JPEGformat image file.

The JPEG is an acronym of Joint Photographic Experts Group andrepresents a widely-used standard method for compressing an image.Extension names for such format include .jpeg, .jfif, .jpg, .JPG, or.JPE. It can be understood that the foregoing is merely examples of theformat of the photographs formed eventually and should not be understoodas a limitation to the format.

In the photograph processing method provided in this embodiment of thepresent invention, a left eye area and a right eye area are calculatedfrom a detected human face, and then stretching transformation isperformed on each pixel in the eye areas, so as to generate a processedphotograph, having an effect of automatically beautifying the eyeswithout the need for manual operation. In addition, the processingeffect is within a controllable range and distortion is not easy tooccur.

In another embodiment of the present disclosure, a basic system for aphotograph processing method is provided. FIG. 4 is a schematic diagramof photograph processing system. The photograph processing systemusually performs execution in a terminal device.

Referring to FIG. 4, the photograph processing system 400 includes adetection module 41, an alignment module 42, an area module 43, astretching module 44, and an equalization module 45, etc.

The detection module 41 is configured to perform face detection on aphotograph to detect positions of all human faces and corresponding faceattributes in a specified image.

The detection module 41 includes a position sub-module 411, an attributesub-module 412, a mode sub-module 413, and a quantity sub-module 414.

Specifically, the position sub-module 411 is configured to performdetection on the photograph to determine the position of the human face(x, y, w, h), so as to describe a position, the width, and the height ofa human face frame, such as an upper left corner horizontal coordinate xof the human face frame, an upper left corner vertical coordinate y ofthe human face frame, the width of the human face frame, and the heightof the human face frame.

The attribute sub-module 412 is configured to detect face attributesaccording to the position of the human face. The face attributes includebut are not limited to one of gender, age, expression, posture (pitch,roll, and yaw), or glasses.

The mode sub-module 413 is configured to detect whether a mode of thephotograph is a normal mode, where an abnormal mode is usually a bigface mode, and, for example, a common big face mode is an ID photographor a selfie.

The quantity sub-module 414 is configured to detect the number of thehuman faces in the photograph to determine whether to process all thehuman faces in the photograph.

The alignment module 42 connected to the detection module 41 isconfigured to perform alignment on the detected human face, so as toobtain contour points of two eyes of the detected human face.

The alignment module 42 includes a locating sub-module 421 and a contoursub-module 422.

Specifically, the locating sub-module 421 is configured to locate facialfeatures of the human face and calculate contour points constituting thehuman face.

The contour sub-module 422 is connected to the locating sub-module 421and is configured to extract coordinate values of contour points of aleft eye and coordinate values of contour points of a right eye from thecontour points.

The area module 43 is connected to the alignment module 42 and isconfigured to separately calculate a left eye area and a right eye areaaccording to the contour points of the two eyes.

The stretching module 44 is connected to the area module 43 and isconfigured to perform stretching transformation on each pixel in theleft eye area and the right eye area.

The stretching module 44 includes a decomposition sub-module 441 and atransformation sub-module 442.

Specifically, the decomposition sub-module 441 is configured todecompose each pixel in the left eye area and the right eye area into ared attribute value, a green attribute value, and a blue attributevalue.

The transformation sub-module 442 is connected to the decompositionsub-module 441 and is configured to perform stretching transformation onthe red attribute value, the green attribute value, and the blueattribute value to generate a stretched left eye area and a stretchedright eye area.

Specifically, the transformation sub-module 442 is configured to obtainoriginal color attribute values, the color attribute values including:red, green, or blue; separately insert the original color attributevalues into a sine function to perform stretching, so as to generatestretched color attribute values; and separately form the stretched lefteye area and the stretched right eye area according to the stretchedcolor attribute values.

A transformation function formed by the sine function is:

F(c)=(sin((c+1.57)*3)+1)/2 0=<c=<1; and the stretched attribute valueis:

C=255*F(c/255.0), c being the red attribute value, the green attributevalue, or the blue attribute value.

By means of the above stretching, the center area of the eye is scaledup and an edge area of the eye is scaled down, so that the eye isrounder and brighter. In addition, a transformation range iscontrollable, and the eyes will not be so large as to cause distortion.

Taking pixels in the left eye area as an example, original R (red) G(green) B (blue) channel values of a pixel are r, g, b, so thattransformed RGB values are:

R=255*F(r/255.0), G=255*F(g/255.0), B=255*F(b/255.0)

The equalization module 45 is connected to the stretching module 44 andis configured to perform histogram equalization processing on astretched left eye area and a stretched right eye area, so as togenerate a processed photograph.

By means of the histogram equalization processing, gray scales with alarger number of pixels in the left eye area and the right eye area arebroadened, and gray scales with a smaller number of pixels arecompressed, thereby expanding the dynamic range of the original pixels,and improving contrast and variation of gray scale tone, so that thestretched photograph is clearer.

The photograph processing system provided in this embodiment of thepresent invention calculates a left eye area and a right eye area from adetected human face, and then performs stretching transformation on eachpixel in the areas, so as to generate a processed photograph, having aneffect of automatically beautifying the eyes without the need for manualoperation. In addition, the processing effect is within a controllablerange and distortion is not easy to occur.

In another embodiment of the present disclosure, a photograph processingsystem is provided. FIG. 5 is a detailed schematic diagram of aphotograph processing system. The photograph processing system mayperform execution in a terminal device, or a cloud service platform.

Referring to FIG. 5, including the various modules shown in FIG. 4, thephotograph processing system 500 includes an interface module 51, aselection module 52, a decoding module 53, a start module 54, adetection module 41, an alignment module 42, an area module 43, astretching module 44, an equalization module 45, and an encoding module55.

The interface module 51 is configured to display an operation interfaceof the processing system, the operation interface including a selectoption, a beautify option, and a save option.

It can be understood that the interface module 51 supplements to theautomatic beautification provided in the above embodiment. That is,selecting a to-be-processed photograph is performed by a user manually,so that a waste of processing resources caused by processing excessivephotographs by a terminal device can be effectively reduced.

The selection module 52 is connected to the interface module 51 and isconfigured to select the to-be-processed photograph using the selectoption on the operation interface.

It can be understood that the to-be-processed photograph may be selectedby selecting a single photograph, a batch of photographs, a localphotograph, or a network photograph, etc.

The decoding module 53 is connected to the selection module 52 and isconfigured to decode the selected photograph to generate an RGB formatphotograph.

The RGB format, also referred to as a color mode, obtains various colorsby changing three color channels of red (R), green (G), and blue (B),and overlay among them. RGB represents colors of the three channels ofred, green, and blue. Such a standard almost includes all colors thatcan be perceived by human eyes, and is one of the current most widelyused color systems.

The start module 54 is connected to the interface module 51 and isconfigured to start face detection on the selected photograph using thebeautify option.

The beautify option is mainly to beautify the eyes, and may also includeother beautifying steps, such as beautifying skin or removing moles.Details are not further described herein.

The detection module 41 is connected to the start module 54 and thedecoding module 53, and is configured to perform face detection on thephotograph to detect positions of all human faces and corresponding faceattributes in a specified image.

Specifically, the detection module 41 includes: a position sub-module411 configured to perform detection on the photograph to determine aposition of the human face (x, y, w, h); an attribute sub-module 412configured to detect face attributes according to the position of thehuman face; a mode sub-module 413 configured to detect a mode of thephotograph; and a quantity sub-module 414 configured to detect thenumber of the human faces in the photograph to determine whether toprocess all the human faces in the photograph.

The alignment module 42 is connected to the detection module 41 and isconfigured to perform alignment on the detected human face, so as toobtain contour points of the two eyes of the detected human face.

Specifically, the alignment module 42 includes a locating sub-module 421configured to locate facial features of the human face and calculatecontour points constituting the human face; and a contour sub-module 422configured to extract position values (x, y) of contour points of theleft eye and contour points of the right eye from the contour points.

The area module 43 is connected to the alignment module 42 and isconfigured to separately calculate a left eye area and a right eye areaaccording to the contour points of the two eyes.

The stretching module 44 is connected to the area module 43 and isconfigured to perform stretching transformation on each pixel in theleft eye area and the right eye area.

Specifically, the stretching module 44 includes: a decompositionsub-module 441, configured to decompose each pixel in the left eye areaand the right eye area into a red attribute value, a green attributevalue, and a blue attribute value; and a transformation sub-module 442,configured to perform stretching transformation on the red attributevalue, the green attribute value, and the blue attribute value togenerate a stretched left eye area and a stretched right eye area.

The transformation sub-module 442 performs stretching on the attributevalues of the three colors by means of a transformation function, wherethe transformation function is:

F(c)=(sin((c+1.57)*3)+1)/2 0=<c=<1; and

the stretched attribute value is: C=255*F(c/255.0), c being the redattribute value, the green attribute value, or the blue attribute value.

The equalization module 45 is connected to the stretching module 44 andis configured to perform histogram equalization processing on astretched left eye area and a stretched right eye area, so as togenerate a processed photograph.

By means of the histogram equalization processing, gray scales with alarger number of pixels in the left eye area and the right eye area arebroadened, and gray scales with a smaller number of pixels arecompressed, thereby expanding the dynamic range of the original pixels,and improving contrast and variation of gray scale tone, so that thestretched photograph is clearer.

The encoding module 55 is connected to the interface module 51 and theequalization module 45, and is configured to, using the save option fromthe operation interface, encode the photograph after the equalizationprocessing to generate a JPEG format image file.

The photograph processing system provided in this embodiment of thepresent invention calculates a left eye area and a right eye area from adetected human face, and then performs stretching transformation on eachpixel in the areas, so as to generate a processed photograph, having aneffect of automatically beautifying the eyes without the need for manualoperation. In addition, the processing effect is within a controllablerange and distortion is not easy to occur.

In another embodiment of the present disclosure, an interface of aphotograph processing method and system is provided. FIG. 6 is aschematic diagram of the interface of a photograph processing method andsystem. Referring to FIG. 6, the interface 51 (e.g., corresponding tothe interface module 51 in FIG. 5) may include the select option 511,the beautify option 512, the save option 513, and a display area ofresponse information 514.

The interface 51 is configured to display an operation interface of theprocessing system. Specifically, the select option 511 is configured totrigger the selection module 52 and the decoding module 53 in FIG. 5, soas to select a photograph and decode the photograph to generate an RGBformat photograph.

The beautify option 512 is configured to trigger the start module 54,the detection module 41, the alignment module 42, the area module 43,the stretching module 44, and the equalization module 45 in FIG. 5, soas to beautify pupils of human eyes in a photograph. The position of thehuman face is displayed by means of a human face frame (x, y, w, h).

FIG. 7 is a schematic diagram of the contour points according to thisembodiment of the present invention. As shown in FIG. 7, a total of 88contour points are used as an example for description, includingeyebrows (8 points at both left and right), eyes (8 points at both leftand right), a nose (13 points), a mouth (22 points), and a face profile(21 points).

For example, an implementation of the photograph processing method andsystem may use the following request to obtain contour pointinformation.

Request: { “app_id”:“123456”,  //upload person“image”:“asdfasdfasdf12312”, //name of an image or a link address }

The following response may be obtained locally or from the cloudplatform, where the response may be displayed in the display area 514 ofresponse information and fine adjustment may be made by a user to thecontour points; or the response may be used for only backgroundcomputation and not be displayed.

 Response:  {“face_shape”: [ {“face_profile”:[{“x”:48,“y”:55},{“x”:49,“y”:61},{“x”:49,“y”:66},{“x”:50,“y”:71},{“x”:51,“y”:76},{“x”:54,“y”:81},{“x”:56,“y”:86},{“x”:60,“y”:90},{“x”:65,“y”:93},{“x”:71,“y”:95},{“x”:77,“y”:96},{“x”:82,“y”:95},{“x”:87,“y”:93},{“x”:92,“y”:90},{“x”:94,“y”:85},{“x”:97,“y”:81},{“x”:99,“y”:76},{“x”:100,“y”:71},{“x”:101,“y”:65},{“x”:101,“y”:60},{“x”:101,“y”:55}], //faceprofile“left_eye”:[{“x”:62,“y”:55},{“x”:64,“y”:56},{“x”:66,“y”:57},{“x”:68,“y”:57},{“x”:70,“y”:56},{“x”:69,“y”:54},{“x”:66,“y”:54},{“x”:64,“y”:54}], //left eye profile“right_eye”:[{“x”:92,“y”:55},{“x”:90,“y”:56},{“x”:88,“y”:56},{“x”:86,“y”:56},{“x”:84,“y”:56},{“x”:85,“y”:54},{“x”:88,“y”:53},{“x”:90,“y”:54}], //right eye profile“left_eyebrow”, “right_eyebrow”, “mouth”, “nose” and so on are same asthe above, which are omitted herein.        } ],  “image_height”:150, “image_width”:150,  “session_id”:“”  }

The save option 513 is configured to trigger the encoding module 55 inFIG. 5 to encode the photograph after the equalization processing, so asto generate a JPEG format photograph file.

In the photograph processing method and system provided in thisembodiment of the present invention, a left eye area and a right eyearea are calculated from a detected human face, and then stretchingtransformation is performed on each pixel in the areas, so as togenerate a processed photograph, having an effect of automaticallybeautifying the eyes without the need for manual operation. In addition,the processing effect is within a controllable range and distortion isnot easy to occur.

The embodiments of the present invention further provide a storagemedium. The storage medium is further configured to store program codeused to perform the following steps: performing face detection on aphotograph; performing alignment on a detected human face, so as toobtain contour points of two eyes; separately calculating a left eyearea and a right eye area according to the contour points of the twoeyes; performing stretching transformation on each pixel in the left eyearea and the right eye area; and performing histogram equalizationprocessing on the stretched left eye area and the stretched right eyearea, so as to generate a processed photograph.

Optionally, the storage medium is further configured to store programcode used to perform the following steps: decomposing each pixel in theleft eye area and the right eye area into a red attribute value, a greenattribute value, and a blue attribute value; and performing stretchingtransformation on the red attribute value, the green attribute value,and the blue attribute value to generate the stretched left eye area andthe stretched right eye area.

Optionally, the storage medium is further configured to store programcode used to perform the following steps: obtaining original colorattribute values, the color attribute values including: red, green, orblue; separately inserting the original color attribute values into asine function to perform stretching, so as to generate stretched colorattribute values; and separately forming the stretched left eye area andthe stretched right eye area according to the stretched color attributevalues.

Optionally, the storage medium is further configured to store programcode used to perform the following steps: performing detection on thephotograph to determine a position of the human face; and detecting faceattributes according to the position of the human face, the faceattributes including: gender, age, expression, posture, or glasses.

Optionally, the storage medium is further configured to store programcode used to perform the following steps: locating facial features ofthe human face and calculating contour points constituting the humanface; and extracting contour points of a left eye and contour points ofa right eye from the contour points.

Optionally, the storage medium is further configured to store programcode used to perform the following steps: displaying an operationinterface of the processing method, the operation interface including aselect option and a beautify option; selecting the photograph by meansof the select option; decoding the selected photograph to generate anRGB format; and starting the face detection on the selected photographby means of the beautify option.

Optionally, the storage medium is further configured to store programcode used to perform the following steps: when the operation interfacefurther includes a save option, encoding, by using the save option, thephotograph after the equalization processing, so as to generate a JPEGformat photograph file.

The embodiments of the present invention further provide a terminal forimplementing the foregoing photograph processing method. As shown inFIG. 8, the terminal mainly includes a processor 801, a camera 802, adisplay 803, a data interface 804, a memory 805, and a network interface806.

The camera 802 may be configured to take a photograph containing a humanface. The data interface 804 may transmit a photograph of a human facetaken by a third-party tool to the processor 801 by means of datatransmission.

The memory 805 may be configured to store the photograph of the humanface taken by camera 802 or the photograph of the human face shot by thethird-party tool. The network interface 806 may be configured to performnetwork communication with a server. The display 803 may be configuredto display a processed photograph of the human face and an operationinterface.

The processor 801 is mainly configured to execute the followingoperations: performing face detection on the photograph; performingalignment on a detected human face, so as to obtain contour points oftwo eyes; separately calculating a left eye area and a right eye areaaccording to the contour points of the two eyes; performing stretchingtransformation on each pixel in the left eye area and the right eyearea; and performing histogram equalization processing on a stretchedleft eye area and a stretched right eye area, so as to generate aprocessed photograph.

The processor 801 is further configured to perform stretchingtransformation on each pixel in the left eye area and the right eyearea, including: decomposing each pixel in the left eye area and theright eye area into a red attribute value, a green attribute value, anda blue attribute value; and performing stretching transformation on thered attribute value, the green attribute value, and the blue attributevalue to generate a stretched left eye area and a stretched right eyearea.

The processor 801 is further configured to: obtain original colorattribute values, the color attribute values including: red, green, orblue; separately insert the original color attribute values into a sinefunction to perform stretching, so as to generate stretched colorattribute values; and separately form the stretched left eye area andthe stretched right eye area according to the stretched color attributevalues.

The processor 801 is further configured to: perform detection on thephotograph to determine a position of the human face; and detect faceattributes according to the position of the human face, the faceattributes including: gender, age, expression, posture, or glasses.

The processor 801 is further configured to: locate facial features ofthe human face and calculate contour points constituting the human face;and extract contour points of a left eye and contour points of a righteye from the contour points.

The processor 801 is further configured to: display an operationinterface of the processing method, the operation interface including aselect option and a beautify option; select the photograph by means ofthe select option; select the photograph by means of the select option;decode the selected photograph to generate an RGB format; and start theface detection on the selected photograph by means of the beautifyoption.

The operation interface further includes a save option, and theprocessor 801 is further configured to encode, using the save option,the photograph after the equalization processing, so as to generate aJPEG format photograph file.

The photograph processing system and processing method provided in theembodiments of the present invention are based on the same concept. Forthe specific implementation process, refer to the whole specification,and details are not described herein again, and features and elements invarious embodiments may be replaced or combined with other another.

Thus, the present disclosure has been disclosed through preferredembodiments, but the preferred embodiments are not intended to limit thepresent disclosure, and a person of ordinary skill in the art can makevarious modifications and improvements without departing from the spiritand scope of the present disclosure; therefore, the protection scope ofthe present disclosure should be subject to the scope defined by theclaims.

What is claimed is:
 1. A photograph processing method, comprising:performing face detection on a photograph to obtain a detected humanface; performing alignment on the detected human face, so as to obtaincontour points of a left eye and a right eye of the detected human face;separately calculating a left eye area, being an area of the left eye,and a right eye area, being an area of the right eye, according to thecontour points of the left eye and the right eye; performing stretchingtransformation on each pixel in the left eye area and the right eye areato generate a stretched left eye area and a stretched right eye area;and performing histogram equalization processing on the stretched lefteye area and the stretched right eye area, so as to generate a processedphotograph.
 2. The processing method according to claim 1, wherein theperforming stretching transformation on each pixel in the left eye areaand the right eye area comprises: decomposing each pixel in the left eyearea and the right eye area into a red attribute value, a greenattribute value, and a blue attribute value; and performing stretchingtransformation on the red attribute value, the green attribute value,and the blue attribute value of each pixel to generate the stretchedleft eye area and the stretched right eye area.
 3. The processing methodaccording to claim 2, wherein the performing stretching transformationon the red attribute value, the green attribute value, and the blueattribute value to generate the stretched left eye area and thestretched right eye area comprises: separately inserting the redattribute value, the green attribute value, and the blue attribute valueinto a transformation function to perform stretching, so as to generatestretched color attribute values; and separately forming the stretchedleft eye area and the stretched right eye area according to thestretched color attribute values.
 4. The processing method according toclaim 1, wherein the performing face detection on a photographcomprises: performing detection on the photograph to determine aposition of the detected human face; and detecting face attributesaccording to the position of the detected human face.
 5. The processingmethod according to claim 1, wherein the performing alignment on thedetected human face comprises: locating facial features of the detectedhuman face and calculating contour points constituting the detectedhuman face; and extracting contour points of the left eye and contourpoints of the right eye from the contour points.
 6. The processingmethod according to claim 5, wherein, before performing face detectionon a photograph, the processing method further comprises: displaying anoperation interface having at least a select option and a beautifyoption; selecting the photograph using the select option; decoding thephotograph to generate an RGB format photograph; and starting the facedetection on the photograph using the beautify option.
 7. The processingmethod according to claim 6, wherein the operation interface furtherincludes a save option and, after the performing histogram equalizationprocessing on the stretched left eye area and the stretched right eyearea, the processing method further comprises: encoding, using the saveoption, the processed photograph to generate a JPEG format file.
 8. Aphotograph processing system, comprising: a memory storing instructions;and a processor coupled to the memory and, when executing theinstructions, configured for: performing face detection on a photographto obtain a detected human face; performing alignment on the detectedhuman face, so as to obtain contour points of a left eye and a right eyeof the detected human face; separately calculating a left eye area,being an area of the left eye, and a right eye area, being an area ofthe right eye, according to the contour points of the left eye and theright eye; performing stretching transformation on each pixel in theleft eye area and the right eye area to generate a stretched left eyearea and a stretched right eye area; and performing histogramequalization processing on the stretched left eye area and the stretchedright eye area, so as to generate a processed photograph.
 9. Thephotograph processing system according to claim 8, wherein theperforming stretching transformation on each pixel in the left eye areaand the right eye area comprises: decomposing each pixel in the left eyearea and the right eye area into a red attribute value, a greenattribute value, and a blue attribute value; and performing stretchingtransformation on the red attribute value, the green attribute value,and the blue attribute value of each pixel to generate the stretchedleft eye area and the stretched right eye area.
 10. The photographprocessing system according to claim 9, wherein the performingstretching transformation on the red attribute value, the greenattribute value, and the blue attribute value to generate the stretchedleft eye area and the stretched right eye area comprises: separatelyinserting the red attribute value, the green attribute value, and theblue attribute value into a transformation function to performstretching, so as to generate stretched color attribute values; andseparately forming the stretched left eye area and the stretched righteye area according to the stretched color attribute values.
 11. Thephotograph processing system according to claim 8, wherein theperforming face detection on a photograph comprises: performingdetection on the photograph to determine a position of the detectedhuman face; and detecting face attributes according to the position ofthe detected human face.
 12. The photograph processing system accordingto claim 8, wherein the performing alignment on the detected human facecomprises: locating facial features of the detected human face andcalculating contour points constituting the detected human face; andextracting contour points of the left eye and contour points of theright eye from the contour points.
 13. The photograph processing systemaccording to claim 12, wherein, before performing face detection on aphotograph, the processor is further configured for: displaying anoperation interface having at least a select option and a beautifyoption; selecting the photograph using the select option; decoding thephotograph to generate an RGB format photograph; and starting the facedetection on the photograph using the beautify option.
 14. Thephotograph processing system according to claim 13, wherein theoperation interface further includes a save option and, after theperforming histogram equalization processing on the stretched left eyearea and the stretched right eye area, the processor is furtherconfigured for: encoding, using the save option, the processedphotograph to generate a JPEG format file.
 15. A non-transitorycomputer-readable storage medium containing computer-executableinstructions for, when executed by a processor, performing a photographprocessing method, the method comprising: performing face detection on aphotograph to obtain a detected human face; performing alignment on thedetected human face, so as to obtain contour points of a left eye and aright eye of the detected human face; separately calculating a left eyearea, being an area of the left eye, and a right eye area, being an areaof the right eye, according to the contour points of the left eye andthe right eye; performing stretching transformation on each pixel in theleft eye area and the right eye area to generate a stretched left eyearea and a stretched right eye area; and performing histogramequalization processing on the stretched left eye area and the stretchedright eye area, so as to generate a processed photograph.
 16. Thenon-transitory computer-readable storage medium according to claim 15,wherein the performing stretching transformation on each pixel in theleft eye area and the right eye area comprises: decomposing each pixelin the left eye area and the right eye area into a red attribute value,a green attribute value, and a blue attribute value; and performingstretching transformation on the red attribute value, the greenattribute value, and the blue attribute value of each pixel to generatethe stretched left eye area and the stretched right eye area.
 17. Thenon-transitory computer-readable storage medium according to claim 16,wherein the performing stretching transformation on the red attributevalue, the green attribute value, and the blue attribute value togenerate the stretched left eye area and the stretched right eye areacomprises: separately inserting the red attribute value, the greenattribute value, and the blue attribute value into a transformationfunction to perform stretching, so as to generate stretched colorattribute values; and separately forming the stretched left eye area andthe stretched right eye area according to the stretched color attributevalues.
 18. The non-transitory computer-readable storage mediumaccording to claim 15, wherein the performing face detection on aphotograph comprises: performing detection on the photograph todetermine a position of the detected human face; and detecting faceattributes according to the position of the detected human face.
 19. Thenon-transitory computer-readable storage medium according to claim 15,wherein the performing alignment on the detected human face comprises:locating facial features of the detected human face and calculatingcontour points constituting the detected human face; and extractingcontour points of the left eye and contour points of the right eye fromthe contour points.
 20. The non-transitory computer-readable storagemedium according to claim 19, wherein, before performing face detectionon a photograph, the method further comprises: displaying an operationinterface having at least a select option and a beautify option;selecting the photograph using the select option; decoding thephotograph to generate an RGB format photograph; and starting the facedetection on the photograph using the beautify option.